<template>
  <a-modal
    centered
    v-model="visible"
    @cancel="cancel"
    title="入库申请"
    width="80%"
  >
    <template slot="footer">
      <a-button
        v-if="viewBtnFlag != 'pass'"
        @click="cancel"
        style="background: #d7d7d7; color: #fff; border: none"
        >关闭</a-button
      >
      <a-button
        v-if="modalFlage != 'look'"
        :loading="loading"
        type="primary"
        @click="handleOk"
        >确认</a-button
      >
      <a-popconfirm
        v-if="TransferOutKeys == '在途中'"
        title="确认无误并接收？"
        ok-text="确定"
        cancel-text="取消"
        @confirm="chcekBtn('recei')"
      >
        <a-button :loading="loading" type="primary">确认接收</a-button>
      </a-popconfirm>
      <a-button
        v-if="TransferOutKeys == '已接收'"
        :loading="loading"
        style="background: #d7d7d7; color: #fff; border: none"
        @click="chcekBtn('back')"
        >退回</a-button
      >
    </template>

    <h3>转运标题</h3>
    <a-form-model
      class="zxmx"
      ref="addForm"
      :rules="addFormRules"
      :model="addFormData"
    >
      <a-form-model-item style="width: 100%" prop="transferTitle">
        <a-input
          v-if="modalFlage != 'look'"
          v-model="dto.transferTitle"
          placeholder="转运标题"
          :maxLength="50"
        />
        <span v-else>{{ dto.transferTitle }}</span>
      </a-form-model-item>
      <h3 style="width: 100%">
        装箱明细
        <span style="color: #f00; font-size: 14px">带星号的为必填项！</span>
      </h3>

      <a-form-model-item label="入库仓库：" prop="warehouse">
        <a-select
          ref="warehousing"
          show-search
          placeholder="请选择"
          option-filter-prop="children"
          style="width: 200px"
          :filter-option="filterOption"
          @change="changeWarehouse"
          v-model="addFormData.warehouse"
        >
          <a-select-option
            :disabled="modalFlage == 'look' || transferOutKeys == '3'"
            defaultValue="全部"
            :value="item.warehouseId"
            v-for="item in clientWareHouse"
            :key="item.warehouseId"
            :name="item.titleName"
          >
            {{ item.titleName }}
          </a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item label="业务类型：" prop="busTypes">
        <a-select
          ref="warehousing"
          show-search
          placeholder="请选择"
          option-filter-prop="children"
          style="width: 200px"
          :filter-option="filterOption"
          @change="changeBusTypes"
          v-model="addFormData.busTypes"
        >
          <a-select-option
            :disabled="modalFlage == 'look'"
            defaultValue="请选择"
            :value="item.title"
            v-for="item in this.busTypesed"
            :key="item.key"
            :name="item.title"
          >
            {{ item.title }}
          </a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item class="fast">
        <a-checkbox :disabled="modalFlage == 'look' || hasWei" v-model="isFast">
          快进快出
        </a-checkbox>
      </a-form-model-item>
      <a-form-model-item>
        <a-button v-if="modalFlage != 'look'" type="primary" @click="addBox">
          新增箱子
        </a-button>
      </a-form-model-item>
      <a-form-model-item>
        <a-upload
          :beforeUpload="beforeUpload"
          style="margin-left: 15px"
          v-if="modalFlage != 'look'"
          name="file"
          :multiple="false"
          :action="baseUrl + '/by-transfer-warehousing-box/upLoad'"
          :headers="headers"
          @change="importFile"
        >
          <a-button type="primary"> <a-icon type="upload" /> 导入 </a-button>
        </a-upload>
      </a-form-model-item>
      <a-form-model-item v-if="modalFlage != 'look'">
        <a
          @click="upDowBtn"
          style="
            margin-left: 15px;
            color: #2929e0;
            border-bottom: 1px solid #2929e0;
          "
        >
          下载批量导入模板
        </a>
      </a-form-model-item>
    </a-form-model>
    <div class="box-handle">
      <div>
        总预报箱数：<span>{{ boxTotal }}</span>
      </div>
      <div class="handle-right">
        <div>
          总接收箱数：<span>{{ boxAcceptedTotal }}</span>
        </div>
        <div>
          <a-button type="primary" size="small" @click="getLabel"
            >下载转运入库外箱/托盘标签</a-button
          >
          <a-button
            style="margin: 0 5px"
            type="primary"
            size="small"
            @click="acceptDetail"
            >接收明细</a-button
          >
        </div>
      </div>
    </div>
    <!-- 表格 -->
    <a-table
      size="small"
      bordered
      :data-source="dataSource"
      :pagination="false"
      :scroll="{ x: 1200, y: 180 }"
    >
      <!-- 货物编号 -->
      <a-table-column
        key="goodsBoxNo"
        data-index="goodsBoxNo"
        align="center"
        width="8%"
      >
        <span slot="title"> 货物编号</span>
        <template slot-scope="text, record">
          {{ record.goodsBoxNo }}
        </template>
      </a-table-column>
      <!-- 自定义编号 -->
      <a-table-column
        key="customBoxNo"
        data-index="customBoxNo"
        align="center"
        width="10%"
      >
        <span slot="title">自定义编号</span>
        <template slot-scope="text, record">
          <a-input
          :maxLength="128"
            v-if="modalFlage != 'look'"
            size="small"
            style="width: 6rem"
            v-model="record.customBoxNo"
          />
          <span v-else>{{
            record.customBoxNo === "" || record.customBoxNo === null
              ? "暂无"
              : record.customBoxNo
          }}</span>
        </template>
      </a-table-column>
      <!-- sku信息 -->
      <a-table-column
        key="boxList"
        class="columns-tab"
        data-index="boxList"
        align="center"
        width="35%"
      >
        <div slot="title" class="columns">
          <div>商品名称</div>
          <div>商品SKU*数量</div>
        </div>
        <!-- 表格 -->
        <template slot-scope="text, record">
          <ul
            class="boxSkuList-list"
            v-for="item in record.boxSkuList"
            :key="item.key"
          >
            <li>
              {{ item.chineseName }}
              <span v-if="item.chineseName === ''"></span>
            </li>
            <li>
              <span>
                {{ item.sku + "*" + item.skuTotal }}
              </span>
            </li>
          </ul>
        </template>
      </a-table-column>
      <!-- 预报箱数 -->
      <a-table-column
        key="boxTotal"
        data-index="boxTotal"
        align="center"
        width="8%"
      >
        <span slot="title">预报箱数</span>
        <template slot-scope="text, record">
          <span>
            {{ record.boxTotal }}
          </span>
        </template>
      </a-table-column>
      <!-- 已接收箱数 -->
      <a-table-column
        key="boxAcceptedTotal"
        data-index="boxAcceptedTotal"
        align="center"
        width="8%"
      >
        <span slot="title">已接收箱数</span>
        <template slot-scope="text, record">
          <span>
            {{ record.boxAcceptedTotal }}
          </span>
        </template>
      </a-table-column>
      <!-- 待处理箱数 -->
      <a-table-column
        key="boxWaitTotal"
        data-index="boxWaitTotal"
        align="center"
        width="8%"
      >
        <span slot="title">待处理箱数</span>
        <template slot-scope="text, record">
          <span>
            {{ record.boxWaitTotal }}
          </span>
        </template>
      </a-table-column>

      <!-- 长宽高 -->
      <a-table-column key="long" data-index="long" align="center" width="18%">
        <span slot="title">长*宽*高(cm)</span>
        <template slot-scope="text, record" class="box-sizes">
          <span> {{ record.long }}*</span>
          <span> {{ record.width }}* </span>
          <span>
            {{ record.height }}
          </span>
        </template>
      </a-table-column>

      <!-- 重量 -->
      <a-table-column
        key="caratNumber1"
        data-index="caratNumber1"
        align="center"
        width="8%"
      >
        <span slot="title"> <span style="color: red">*</span>重量(kg)</span>
        <template slot-scope="text, record">
          <span>
            {{ record.weight }}
          </span>
        </template>
      </a-table-column>
      <!-- 入库清点 -->
      <a-table-column
        key="Counting"
        data-index="Counting"
        align="center"
        width="8%"
      >
        <span slot="title">入库清点</span>
        <template slot-scope="text, record">
          <a-switch
            @change="(checked) => changeCheck(checked, record)"
            :disabled="modalFlage === 'look'"
            :defaultChecked="record.isCheck == 1 ? true : false"
          />
        </template>
      </a-table-column>
      <!-- 操作 -->
      <a-table-column width="150px" align="center">
        <span slot="title">扫描外箱标</span>
        <template slot-scope="text, record">
          <a
            @click="() => receive(record)"
            href="javascript:;"
            style="
              margin-left: 15px;
              color: #2929e0;
              border-bottom: 1px solid #2929e0;
            "
            >扫描查看/接收</a
          >
        </template>
      </a-table-column>
    </a-table>
    <!-- 头程物流 -->
    <div class="logistics">
      <h3 style="margin-top: 20px">头程物流</h3>
      <span style="color: red; margin-left: 15px"
        >注：选择物流信息后，头程信息为必填项！</span
      >
      <span>物流方式：</span>
      <a-select
        size="small"
        show-search
        style="width: 14rem"
        option-filter-prop="children"
        :filter-option="filterOption"
        @change="changeLogisticsName"
        v-model="dto.logisticsId"
      >
        <a-select-option
          :disabled="modalFlage == 'look'"
          :value="item.key"
          v-for="item in this.express"
          :key="item.key"
          :name="item.title"
        >
          {{ item.title }}
        </a-select-option>
      </a-select>

      <div style="margin: 10px 0">
        <a-button
          :disabled="modalFlage == 'look'"
          type="primary"
          @click="addLogi"
          style="margin-left: 15px"
        >
          新增物流
        </a-button>
      </div>
      <a-table
        :data-source="expressList"
        size="small"
        bordered
        :pagination="false"
        :scroll="{ x: 1200, y: 180 }"
      >
        <!-- 快递方式 -->
        <a-table-column
          v-if="dto.logisticsId == '201'"
          key="expressName"
          data-index="expressName"
          align="center"
          width="20%"
        >
          <span slot="title">物流方式</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-select
                :style="
                  record.expressName === '' || record.expressName == undefined
                    ? 'border: 1px solid #f00;border-radius:5px'
                    : ''
                "
                size="small"
                show-search
                style="width: 14rem"
                option-filter-prop="children"
                :filter-option="filterOption"
                placeholder="请选择物流方式"
                @change="
                  (value, option) => changeexpressName(value, option, record)
                "
                v-model="record.expressName"
              >
                <a-select-option
                  :value="item.key"
                  v-for="item in courier"
                  :key="item.key"
                  :name="item.title"
                >
                  {{ item.title }}
                </a-select-option>
              </a-select>
            </span>
            <span v-else>
              {{ record.expressName }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '201'"
          key="trackingNumber"
          data-index="trackingNumber"
          align="center"
          width="20%"
        >
          <span slot="title">运单号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                :style="
                  record.trackingNumber == ''
                    ? 'border: 1px solid #f00;border-radius:5px'
                    : ''
                "
                v-model="record.trackingNumber"
                size="small"
                style="width: 14rem"
                placeholder="输入订单号"
              />
            </span>
            <span v-else>
              {{ record.trackingNumber }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '201'"
          key="goodsNo"
          data-index="goodsNo"
          align="center"
          width="20%"
        >
          <span slot="title">货物编号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                :style="
                  record.goodsNo == ''
                    ? 'border: 1px solid #f00;border-radius:5px'
                    : ''
                "
                v-model="record.goodsNo"
                size="small"
                placeholder="输入货物编号"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.goodsNo }}
            </span>
          </template>
        </a-table-column>
        <!-- 空运方式 -->
        <a-table-column
          v-if="dto.logisticsId == '202'"
          key="flightNo"
          data-index="flightNo"
          align="center"
          width="17%"
        >
          <span slot="title">头程航班号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.flightNo"
                size="small"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.flightNo }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '202'"
          key="fbaSeriveName"
          data-index="fbaSeriveName"
          align="center"
          width="17%"
        >
          <span slot="title">头程物流商 </span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.fbaSeriveName"
                size="small"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.fbaSeriveName }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '202'"
          key="fbaLogisticsNo"
          data-index="fbaLogisticsNo"
          align="center"
          width="17%"
        >
          <span slot="title">头程物流号 </span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.fbaLogisticsNo"
                size="small"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.fbaLogisticsNo }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '202'"
          key="fbaStartTime"
          data-index="fbaStartTime"
          align="center"
          width="17%"
        >
          <span slot="title">头程航班日期 </span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-date-picker
                @change="
                  (date, dateString) => changeFbaTime(date, dateString, record)
                "
                v-model="record.fbaStartTime"
                size="small"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.fbaStartTime }}
            </span>
          </template>
        </a-table-column>
        <!-- 海运方式 -->
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingNo"
          data-index="shippingNo"
          align="center"
          width="11%"
        >
          <span slot="title">头程货运船号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input :maxLength="128" v-model="record.shippingNo" size="small" />
            </span>
            <span v-else>
              {{ record.shippingNo }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingCabinetNo"
          data-index="shippingCabinetNo"
          align="center"
          width="11%"
        >
          <span slot="title">头程货运柜号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input :maxLength="128" v-model="record.shippingCabinetNo" size="small" />
            </span>
            <span v-else>
              {{ record.shippingCabinetNo }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingCabinetType"
          data-index="shippingCabinetType"
          align="center"
          width="11%"
        >
          <span slot="title">头程货柜型号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input :maxLength="128" v-model="record.shippingCabinetType" size="small" />
            </span>
            <span v-else>
              {{ record.shippingCabinetType }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingHbl"
          data-index="shippingHbl"
          align="center"
          width="11%"
        >
          <span slot="title">头程hbl</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input :maxLength="128" v-model="record.shippingHbl" size="small" />
            </span>
            <span v-else>
              {{ record.shippingHbl }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingMbl"
          data-index="shippingMbl"
          align="center"
          width="11%"
        >
          <span slot="title">头程货mbl</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input :maxLength="128" v-model="record.shippingMbl" size="small" />
            </span>
            <span v-else>
              {{ record.shippingMbl }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingStartTime"
          data-index="shippingStartTime"
          align="center"
          width="11%"
        >
          <span slot="title">头程开船日期</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-date-picker
                @change="
                  (date, dateString) =>
                    changeShiStartTime(date, dateString, record)
                "
                v-model="record.shippingStartTime"
                size="small"
                style="width: 9rem"
              />
            </span>
            <span v-else>
              {{ record.shippingStartTime }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '203'"
          key="shippingEndTime"
          data-index="shippingEndTime"
          align="center"
          width="11%"
        >
          <span slot="title">头程到仓日期</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-date-picker
                @change="
                  (date, dateString) =>
                    changeShiEndTime(date, dateString, record)
                "
                v-model="record.shippingEndTime"
                size="small"
                style="width: 9rem"
              />
            </span>
            <span v-else>
              {{ record.shippingEndTime }}
            </span>
          </template>
        </a-table-column>
        <!-- 卡车方式 -->
        <a-table-column
          v-if="dto.logisticsId == '204'"
          key="lorryChannelName"
          data-index="lorryChannelName"
          align="center"
          width="16%"
        >
          <span slot="title">卡派方式</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-select
                size="small"
                show-search
                style="width: 13rem"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="
                  (value, option) =>
                    changeLorryChannelName(value, option, record)
                "
                v-model="record.lorryChannelName"
              >
                <a-select-option
                  :value="item.key"
                  v-for="item in cardSend"
                  :key="item.key"
                  :name="item.title"
                >
                  {{ item.title }}
                </a-select-option>
              </a-select>
            </span>
            <span v-else>
              {{ record.lorryChannelName }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '204'"
          key="licensePlate"
          data-index="licensePlate"
          align="center"
          width="16%"
        >
          <span slot="title">车牌号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-select
                size="small"
                show-search
                style="width: 13rem"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="
                  (value, option) => changeLicensePlate(value, option, record)
                "
                v-model="record.licensePlate"
              >
                <a-select-option
                  :value="item.key"
                  v-for="item in License"
                  :key="item.key"
                  :name="item.title"
                >
                  {{ item.title }}
                </a-select-option>
              </a-select>
            </span>
            <span v-else>
              {{ record.licensePlate }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '204'"
          key="cargoNo"
          data-index="cargoNo"
          align="center"
          width="16%"
        >
          <span slot="title">货物编号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.cargoNo"
                style="width: 13rem"
                size="small"
              />
            </span>
            <span v-else>
              {{ record.cargoNo }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsId == '204'"
          key="intOutTime"
          data-index="intOutTime"
          align="center"
          width="16%"
        >
          <span slot="title">入仓时间</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-date-picker
                @change="
                  (date, dateString) =>
                    changeIntOutTime(date, dateString, record)
                "
                v-model="record.intOutTime"
                size="small"
                style="width: 13rem"
              />
            </span>
            <span v-else>
              {{ record.intOutTime }}
            </span>
          </template>
        </a-table-column>
        <!-- 公用的文件和删除上传 -->
        <a-table-column
          key="uploadFile.url"
          data-index="uploadFile.url"
          align="center"
          :width="dto.logisticsId == '203' ? '11%' : '20%'"
        >
          <span slot="title">文件</span>
          <template slot-scope="text, record">
            <span>
              <a :href="record.uploadFile.url" target="_blank">{{
                record.uploadFile.fileText
              }}</a>
            </span>
          </template>
        </a-table-column>

        <a-table-column
          key="operation"
          data-index="operation"
          title="操作"
          align="center"
          width="200"
        >
          <template slot-scope="text, record">
            <a-popconfirm
              v-if="modalFlage != 'look'"
              title="确定删除吗?"
              @confirm="() => DeleteLogi(record, record.key)"
            >
              <a
                href="javascript:;"
                style="
                  color: rgb(243, 56, 29);
                  border-bottom: 1px solid rgb(243, 56, 29);
                  margin-right: 15px;
                "
                >删除</a
              >
            </a-popconfirm>
            <a-upload
              v-if="modalFlage != 'look'"
              :beforeUpload="beforeUploads"
              name="file"
              :action="baseUrl + '/by-file/uploadFile'"
              :headers="headers"
              @change="(info) => handle(info, record)"
              :showUploadList="false"
            >
              <a
                style="color: #0000bf; border-bottom: 1px solid #0000bf"
                href="javascript:;"
                >上传文件</a
              >
            </a-upload>
          </template>
        </a-table-column>
      </a-table>
    </div>
    <!-- 尾程物流 -->
    <div v-if="isFast" class="logistics">
      <h3 style="margin-top: 20px">尾程物流</h3>
      <span style="color: red; margin-left: 15px"
        >注：选择快进快出物流方式后，尾程信息为必填项！</span
      >
      <a-form-model
        :model="dto"
        class="wei-logi"
        :rules="inOutRules"
        ref="inOutForm"
      >
        <a-form-model-item label="物流方式：">
          <a-select
            size="small"
            show-search
            style="width: 14rem"
            option-filter-prop="children"
            :filter-option="filterOption"
            placeholder="请选择"
            @change="changeLogisticsNameWei"
            v-model="dto.logisticsIdWei"
          >
            <a-select-option
              :disabled="modalFlage == 'look'"
              :value="item.key"
              v-for="item in this.expressWei"
              :key="item.key"
              :name="item.title"
            >
              {{ item.title }}
            </a-select-option>
          </a-select>
        </a-form-model-item>
        <a-form-model-item
          v-if="dto.logisticsIdWei != '' && dto.logisticsIdWei != '未选择'"
          label="收件人："
          prop="fastInOutConsignee"
        >
          <a-input
          :maxLength="128"
            v-if="modalFlage != 'look'"
            size="small"
            v-model="dto.fastInOutConsignee"
          />
          <span v-else>
            {{ dto.fastInOutConsignee }}
          </span>
        </a-form-model-item>
        <a-form-model-item
          label="联系电话："
          prop="fastInOutPhone"
          v-if="dto.logisticsIdWei != '' && dto.logisticsIdWei != '未选择'"
        >
          <a-input
          :maxLength="128"
            v-if="modalFlage != 'look'"
            size="small"
            v-model="dto.fastInOutPhone"
          />
          <span v-else>
            {{ dto.fastInOutPhone }}
          </span>
        </a-form-model-item>
        <a-form-model-item
          class="fastaddr"
          label="收件地址："
          prop="fastInOutAddress"
          v-if="dto.logisticsIdWei != '' && dto.logisticsIdWei != '未选择'"
        >
          <a-input
          :maxLength="128"
            v-if="modalFlage != 'look'"
            size="small"
            v-model="dto.fastInOutAddress"
          />
          <span v-else>
            {{ dto.fastInOutAddress }}
          </span>
        </a-form-model-item>
      </a-form-model>
      <a-button
        :disabled="modalFlage == 'look'"
        type="primary"
        @click="addLogiWei"
        style="margin-bottom: 10px"
      >
        新增物流
      </a-button>
      <a-table
        :data-source="expressListWei"
        size="small"
        bordered
        :pagination="false"
        :scroll="{ x: 1200, y: 180 }"
      >
        <!-- 快递方式 -->
        <a-table-column
          v-if="dto.logisticsIdWei == '201'"
          key="expressName"
          data-index="expressName"
          align="center"
          width="20%"
        >
          <span slot="title">物流方式</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-select
                size="small"
                show-search
                style="width: 14rem"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="
                  (value, option) => changeexpressNameWei(value, option, record)
                "
                v-model="record.expressName"
              >
                <a-select-option
                  :value="item.key"
                  v-for="item in courier"
                  :key="item.key"
                  :name="item.title"
                >
                  {{ item.title }}
                </a-select-option>
              </a-select>
            </span>
            <span v-else>
              {{ record.expressName }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsIdWei == '201'"
          key="trackingNumber"
          data-index="trackingNumber"
          align="center"
          width="20%"
        >
          <span slot="title">运单号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.trackingNumber"
                size="small"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.trackingNumber }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsIdWei == '201'"
          key="goodsNo"
          data-index="goodsNo"
          align="center"
          width="20%"
        >
          <span slot="title">货物编号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.goodsNo"
                size="small"
                style="width: 14rem"
              />
            </span>
            <span v-else>
              {{ record.goodsNo }}
            </span>
          </template>
        </a-table-column>
        <!-- 卡车方式 -->
        <a-table-column
          v-if="dto.logisticsIdWei == '204'"
          key="lorryChannelName"
          data-index="lorryChannelName"
          align="center"
          width="16%"
        >
          <span slot="title">卡派方式</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-select
                size="small"
                show-search
                style="width: 13rem"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="
                  (value, option) =>
                    changeLorryChannelName(value, option, record)
                "
                v-model="record.lorryChannelName"
              >
                <a-select-option
                  :value="item.key"
                  v-for="item in cardSend"
                  :key="item.key"
                  :name="item.title"
                >
                  {{ item.title }}
                </a-select-option>
              </a-select>
            </span>
            <span v-else>
              {{ record.lorryChannelName }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsIdWei == '204'"
          key="licensePlate"
          data-index="licensePlate"
          align="center"
          width="16%"
        >
          <span slot="title">车牌号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-select
                size="small"
                show-search
                style="width: 13rem"
                option-filter-prop="children"
                :filter-option="filterOption"
                @change="
                  (value, option) => changeLicensePlate(value, option, record)
                "
                v-model="record.licensePlate"
              >
                <a-select-option
                  :value="item.key"
                  v-for="item in License"
                  :key="item.key"
                  :name="item.title"
                >
                  {{ item.title }}
                </a-select-option>
              </a-select>
            </span>
            <span v-else>
              {{ record.licensePlate }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsIdWei == '204'"
          key="cargoNo"
          data-index="cargoNo"
          align="center"
          width="16%"
        >
          <span slot="title">货物编号</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-input
              :maxLength="128"
                v-model="record.cargoNo"
                style="width: 13rem"
                size="small"
              />
            </span>
            <span v-else>
              {{ record.cargoNo }}
            </span>
          </template>
        </a-table-column>
        <a-table-column
          v-if="dto.logisticsIdWei == '204'"
          key="intOutTime"
          data-index="intOutTime"
          align="center"
          width="16%"
        >
          <span slot="title">入仓时间</span>
          <template slot-scope="text, record">
            <span v-if="modalFlage != 'look'">
              <a-date-picker
                @change="
                  (date, dateString) =>
                    changeIntOutTime(date, dateString, record)
                "
                v-model="record.intOutTime"
                size="small"
                style="width: 13rem"
              />
            </span>
            <span v-else>
              {{ record.intOutTime }}
            </span>
          </template>
        </a-table-column>
        <!-- 公用的文件和删除上传 -->
        <a-table-column
          key="uploadFile.url"
          data-index="uploadFile.url"
          align="center"
          :width="dto.logisticsIdWei == '203' ? '11%' : '20%'"
        >
          <span slot="title">文件</span>
          <template slot-scope="text, record">
            <span>
              <a :href="record.uploadFile.url" target="_blank">{{
                record.uploadFile.fileText
              }}</a>
            </span>
          </template>
        </a-table-column>
        <a-table-column
          key="operation"
          data-index="operation"
          title="操作"
          align="center"
          width="200"
        >
          <template slot-scope="text, record" v-if="modalFlage != 'look'">
            <a-popconfirm
              title="确定删除吗?"
              @confirm="() => DeleteLogiWei(record, record.key)"
            >
              <a
                href="javascript:;"
                style="
                  color: rgb(243, 56, 29);
                  border-bottom: 1px solid rgb(243, 56, 29);
                  margin-right: 15px;
                "
                >删除</a
              >
            </a-popconfirm>
            <a-upload
              :beforeUpload="beforeUploads"
              name="file"
              :action="baseUrl + '/by-file/uploadFile'"
              :headers="headers"
              @change="(info) => handle(info, record)"
              :showUploadList="false"
            >
              <a
                style="color: #0000bf; border-bottom: 1px solid #0000bf"
                href="javascript:;"
                >上传文件</a
              >
            </a-upload>
          </template>
        </a-table-column>
      </a-table>
    </div>
    <div
      v-if="
        transferOutKeys == '4' ||
        transferOutKeys == '5' ||
        transferOutKeys == '6'
      "
    >
      <h3 style="margin-top: 20px">
        服务选择
        <a-tooltip placement="topLeft">
          <template slot="title">
            其中包含仓储费、订单处理费、复合订单包装 费、材料费、增值服务费
            1、仓储费、订单处理费、复合订单包装费为一
            件代发默认收费项；收费标准以实际合同为主。
            2、材料费、增值服务费为货物到仓之后所产生
            额外服务收费项，具体收费以仓库所使用材料和 使用哪些增值服务具体收费
          </template>
          <a-icon
            style="color: #3eae7c"
            type="question-circle"
            theme="filled"
          />
        </a-tooltip>
      </h3>
      <div>
        <a-button type="primary" @click="goService">服务项登记</a-button>
      </div>
    </div>
    <!-- 备注 -->
    <h3 style="margin-top: 20px">备注</h3>
    <a-textarea
      v-if="modalFlage != 'look'"
      :maxLength="256"
      style="width: 100%"
      v-model="dto.remarks"
      :auto-size="{ minRows: 2 }"
    />
    <span v-else>{{ dto.remarks }}</span>
    <TransferInReceiveModal
      :searchData="dto"
      :sreachBoxInfo="sreachBoxInfo"
      :TransferOutKeys="TransferOutKeys"
      :getTransferInTableList="getTransferInTableList"
    />
    <TransferInserviceModal :searchOne="searchOne" />
    <ServiceModalReap
      :getModalData="searchOne"
      :transferWarehousingApplyId="dto.transferWarehousingApplyId"
    />
  </a-modal>
</template>

<script>
import { upDow } from "@/apis/clientSide/OrderManage/Instock.js";
import TransferInReceiveModal from "./TransferInReceiveModal";
import TransferInserviceModal from "./TransferInserviceModal";
import ServiceModalReap from "@/components/serviceModal/ServiceModalReap";
import baseUrl from "@/utils/baseUrl";

import { downTransLabel } from "@/apis/common";
import {
  warehouse_select,
  treeTagDictionary,
  sku_select,
  removefile,
  SKU_PDF6030,
} from "@/apis/common";
import {
  box_no,
  transferIn_save,
  getByApplyId,
  updateApplyInfo,
  update_ascertained,
  updateWaitSendFba,
  backautit4,
  searchBoxInfo,
  warehousingBoxInfo,
} from "@/apis/clientSide/OrderManage/TransferIn";
import req from "@/utils/req";
import { mapState } from "vuex";
export default {
  components: {
    TransferInReceiveModal,
    TransferInserviceModal,
    ServiceModalReap,
  },
  inject: ["reload"],
  props: [
    "getTransferInTableList",
    "getStateCount",
    "tabKeys",
    "transferOutKeys",
  ],
  computed: {
    ...mapState(["clientWareHouse"]),
  },
  created() {
    this.getSelection();
  },
  data() {
    return {
      boxTotal: "",
      boxAcceptedTotal: "",

      iszdmx: "",
      hasWei: false,
      //尾程信息
      //快递方式选择
      express: [],
      expressWei: [
        { key: "201", title: "快递方式", value: "201" },
        { key: "204", title: "卡派方式", value: "204" },
      ],
      //卡派选择方式
      License: [
        { key: "1", title: "4654w1" },
        { key: "2", title: "川A2522" },
      ],
      cardSend: [
        { key: "1", title: "卡车公司1" },
        { key: "2", title: "卡车公司2" },
      ],

      //仓库信息
      warehouse: [],
      //快递选择
      courier: [
        { value: "usps", title: "usps", key: "1" },
        { value: "FedEx", title: "FedEx", key: "2" },
      ],
      busTypesed: [
        { title: "普通转运", value: "普通转运", key: 1 },
        { title: "其他仓库转运", value: "其他仓库转运", key: 2 },
      ],
      addFormData: {
        warehouse: undefined,
        busTypes: undefined,
      },
      //仓库自提需上传相关文件
      selfExtractFile: "",

      uploadExcelFlag: false,
      //   定义验证规则
      addFormRules: {
        warehouse: [
          { validator: this.checkWarehouse, trigger: "blur", required: true },
        ],
        busTypes: [
          { validator: this.checkBusTypes, trigger: "blur", required: true },
        ],
      },
      inOutRules: {
        fastInOutAddress: [
          { message: "请输入收件地址！", trigger: "blur", required: true },
        ],
        fastInOutConsignee: [
          { message: "请输入收件人姓名！", trigger: "blur", required: true },
        ],
        fastInOutPhone: [
          {
            message: "请输入收件人联系电话！",
            trigger: "blur",
            required: true,
          },
        ],
      },
      viewBtnFlag: "",
      //模态框标杆
      modalFlage: "",
      isFast: false,
      refuseLogin: false,
      loading: false,
      fileList: [],
      baseUrl,
      passFlag: false,
      flightTime: null,
      expressTime: null,
      boatTime: null,
      styleBack: {
        border: "1px solid #f00",
        borderRadius: "5px",
      },
      styleYes: {
        border: "1px solid #ccc",
        borderRadius: "5px",
      },
      key: 1,
      //sku列表
      skuList: [],
      //文件时上传请求头
      headers: {
        authorization: "authorization-text",
        // ContentType: '["multipart/form-data"]',
        token: sessionStorage.getItem("tk"),
      },

      // 费用信息选择值
      costValue: [],
      costOptions: [{ label: "清关服务", value: "0" }],
      // 费用信息

      // 到仓配送
      dispatchingOptions: [
        { label: "卡车配送", value: "0" },
        { label: "整柜派送", value: "1" },
        { label: "快递", value: "2" },
        { label: "仓库提货", value: "3" },
      ],
      // 模态框显示
      visible: false,
      //表格数据
      dataSource: [],
      boxlistObj: {
        chineseName: "",
        sku: "",
        skuId: "",
        skuTotal: "",
        uiIsDelete: null,
      },
      //头程的物流信息
      expressList: [],
      //尾程 的物流信息
      expressListWei: [],

      dto: {
        boxList: [],
        logisticsType: "", //物流类型
        transferTitle: "", //转运表标题
        businessType: "",
        // deliveryTime: "",
        logisticsId: "未选择",
        fastInOut: 0,
        logisticsIdWei: "未选择",
        logisticsName: "",
        remarks: "",
        logisticsTypeInOut: null,
        airFreightsInOutList: [],
        expressInOutList: [],
        lorryInOutList: [],
        shippingInOutList: [],
        shippingList: [],
        lorryList: [],
        expressList: [],
        airFreightsList: [],
        warehousingId: "未选择",
        warehousingName: "",
        uiIsDelete: null,
        fastInOutAddress: "", //快进快出联系地址
        fastInOutConsignee: "", //快进快出联系人
        fastInOutPhone: "", //快进快出联系电话
      },
      TransferOutKeys: "",
    };
  },
  mounted() {
    //新增打开模态框
    this.$bus.$off("showTransferInAddModal");
    this.$bus.$on("showTransferInAddModal", () => {
      for (let key in this.dto) {
        this.dto[key] = "";
      }
      this.dto.boxList = {
        goods: "",
        weight: "",
        height: "",
        isCheck: "",
        Counting: false,
        long: "",
        width: "",
        uiIsDelete: null,
      };
      this.expressList = [];
      this.expressListWei = [];
      this.dto.logisticsId = "未选择";
      this.dto.logisticsIdWei = "未选择";
      this.dto.logisticsName = "";
      this.dto.warehousingId = "未选择";
      this.dataSource = [];
      this.isFast = false;
      this.costValue = [];
      this.dto.fastInOut = 0;
      this.flightTime = null;
      this.addFormData.warehouse = undefined;
      this.addFormData.busTypes = undefined;
      this.visible = true;
      this.modalFlage = "add";
      this.dto.airFreightsInOutList = [];
      this.dto.expressInOutList = [];
      this.dto.lorryInOutList = [];
      this.dto.shippingInOutList = [];
      this.dto.shippingList = [];
      this.dto.lorryList = [];
      this.dto.expressList = [];
      this.dto.airFreightsList = [];
    });
    //编辑、详情
    this.$bus.$off("TransferInRowData2");
    this.$bus.$on(
      "TransferInRowData2",
      (id, flag, viewBtnFlag, TransferOutKeys) => {
        this.modalFlage = flag;
        this.editFlag = flag;
        this.viewBtnFlag = viewBtnFlag;
        this.TransferOutKeys = TransferOutKeys;
        if (id) {
          this.searchOne(id);
        }
      }
    );
  },
  methods: {
    goService() {
      if (this.dto.isServiceItem < 1 && this.transferOutKeys == "4") {
        this.$bus.$emit("serviceRegistration", true, this.dto);
      }
      if (this.dto.isServiceItem >= 1 && this.transferOutKeys == "4") {
        this.$bus.$emit(
          "reappearance",
          this.dto,
          0,
          this.dto.transferWarehousingApplyId,
          true,
          "warehouse"
        );
      }
      if (this.transferOutKeys != "4") {
        this.$bus.$emit(
          "reappearance",
          this.dto,
          0,
          this.dto.transferWarehousingApplyId,
          false
        );
      }
    },
    //查询单条
    async searchOne(id) {
      let { code, responseBody } = await getByApplyId(id);
      if (code == "200") {
        this.sreachBoxInfo(responseBody.transferWarehousingApplyId);
        responseBody.logisticsId =
          responseBody.logisticsId === "" ? "未选择" : responseBody.logisticsId;
        responseBody.logisticsIdWei =
          responseBody.logisticsIdWei === ""
            ? "未选择"
            : responseBody.logisticsIdWei;
        this.dataSource = responseBody.boxList;
        this.dataSource.forEach((item) => {
          if (item.boxWaitTotal * 1 < 1) {
            item.boxWaitTotal = 0;
          }
        });
        responseBody.boxList.forEach((item, i) => {
          item.uiIsDelete = 2;
          this.dataSource[i].uiIsDelete = 2;
          if (item.isCheck == "0") {
            this.dataSource[i].Counting = false;
          } else {
            this.dataSource[i].Counting = true;
          }
        });
        //物流方式都 改成2
        if (responseBody.airFreightsInOutList != null) {
          responseBody.airFreightsInOutList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.airFreightsList != null) {
          responseBody.airFreightsList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.expressInOutList != null) {
          responseBody.expressInOutList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.expressList != null) {
          responseBody.expressList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.lorryInOutList != null) {
          responseBody.lorryInOutList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.lorryList != null) {
          responseBody.lorryList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.shippingInOutList != null) {
          responseBody.shippingInOutList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        if (responseBody.shippingList != null) {
          responseBody.shippingList.forEach((val) => {
            val.uiIsDelete = 2;
          });
        }
        this.dto = responseBody;
        // //因为箱子集合提交前会赋值一次，所以先把有的给清空
        if (this.dto.fastInOut == "1") {
          this.isFast = true;
        } else {
          this.isFast = false;
        }
        //装箱明细反显  仓库和业务类型
        //入库仓库
        this.addFormData.warehouse = responseBody.warehousingId;
        //业务类型
        if (responseBody.businessType == "0") {
          this.addFormData.busTypes = "FBA转运";
        } else if (responseBody.businessType == "1") {
          this.addFormData.busTypes = "普通转运";
        } else if (responseBody.businessType == "2") {
          this.addFormData.busTypes = "其他仓库转运";
        }
        //头程物流方式反显
        if (this.dto.logisticsType == "0") {
          this.expressList = JSON.parse(JSON.stringify(this.dto.expressList));
          this.dto.logisticsId = "201";
          this.dto.expressList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
        } else if (this.dto.logisticsType == "1") {
          this.expressList = JSON.parse(JSON.stringify(this.dto.shippingList));
          this.dto.logisticsId = "203";
          this.dto.shippingList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
        } else if (this.dto.logisticsType == "2") {
          this.expressList = JSON.parse(
            JSON.stringify(this.dto.airFreightsList)
          );
          this.dto.logisticsId = "202";
          this.dto.airFreightsList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
        } else if (this.dto.logisticsType == "3") {
          this.expressList = JSON.parse(JSON.stringify(this.dto.lorryList));
          this.dto.logisticsId = "204";
          this.dto.lorryList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
        }
        if (this.expressList.length > 0) {
          this.expressList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
        }

        //尾程物流反显
        if (this.dto.logisticsTypeInOut == "0") {
          this.expressListWei = JSON.parse(
            JSON.stringify(this.dto.expressInOutList)
          );
          this.dto.logisticsIdWei = "201";
          this.dto.expressInOutList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
          this.hasWei = true;
        } else if (this.dto.logisticsTypeInOut == "1") {
          this.expressListWei = JSON.parse(
            JSON.stringify(this.dto.shippingInOutList)
          );
          this.dto.logisticsIdWei = "203";
          this.dto.shippingInOutList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
          this.hasWei = true;
        } else if (this.dto.logisticsTypeInOut == "2") {
          this.expressListWei = JSON.parse(
            JSON.stringify(this.dto.airFreightsInOutList)
          );
          this.dto.logisticsIdWei = "202";
          this.dto.airFreightsInOutList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
          this.hasWei = true;
        } else if (this.dto.logisticsTypeInOut == "3") {
          this.expressListWei = JSON.parse(
            JSON.stringify(this.dto.lorryInOutList)
          );
          this.dto.logisticsIdWei = "204";
          this.dto.lorryInOutList.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
          this.hasWei = true;
        }
        if (this.expressListWei.length > 0) {
          this.expressListWei.forEach((item) => {
            item.uploadFile = JSON.parse(item.uploadFile);
          });
        }

        if (this.dto.logisticsType == "0") {
          this.dto.logisticsId = "201";
        } else if (this.dto.logisticsType == "2") {
          this.dto.logisticsId = "202";
        } else if (this.dto.logisticsType == "1") {
          this.dto.logisticsId = "203";
        } else if (this.dto.logisticsType == "3") {
          this.dto.logisticsId = "204";
        } else {
          this.dto.logisticsId = "未选择";
        }

        if (this.dto.logisticsTypeInOut == "0") {
          this.dto.logisticsIdWei = "201";
        } else if (this.dto.logisticsTypeInOut == "2") {
          this.dto.logisticsIdWei = "202";
        } else if (this.dto.logisticsTypeInOut == "1") {
          this.dto.logisticsIdWei = "203";
        } else if (this.dto.logisticsTypeInOut == "3") {
          this.dto.logisticsIdWei = "204";
        } else {
          this.dto.logisticsIdWei = "未选择";
        }
        this.visible = true;
      }
    },
    //下载外箱标
    async getLabel() {
      let responseBody = await downTransLabel(
        this.dto.transferWarehousingApplyId
      );
      if (responseBody) {
        req.exportPDF(this.dto.transferNo, responseBody);
      }
    },
    //是否清点
    changeCheck(checked, record) {
      record.Counting = checked;
      if (record.Counting == false) {
        record.isCheck = 0;
      } else {
        record.isCheck = 1;
      }
    },
    //改变箱子里面sku的数量
    changeBoxSkuNum(value, record) {
      if (record.byTransferWarehousingBoxSkuId) {
        record.uiIsDelete = 2;
      } else {
        record.uiIsDelete = null;
      }
      value === null ? (value = 1) : value;
    },
    //关闭模态框
    cancel() {
      for (let key in this.dto) {
        this.dto[key] = "";
      }
      this.dto.boxList = {
        goods: "",
        weight: "",
        height: "",
        isCheck: "",
        Counting: false,
        long: "",
        width: "",
        uiIsDelete: null,
      };
      this.expressList = [];
      this.expressListWei = [];
      this.dto.logisticsId = "未选择";
      this.dto.logisticsIdWei = "未选择";
      this.dto.logisticsName = "";
      this.dto.warehousingId = "未选择";
      this.dataSource = [];
      this.isFast = false;
      this.costValue = [];
      this.dto.fastInOut = 0;
      this.flightTime = null;
      this.addFormData.warehouse = undefined;
      this.addFormData.busTypes = undefined;
      this.visible = true;
      this.modalFlage = "add";
      this.dto.airFreightsInOutList = [];
      this.dto.expressInOutList = [];
      this.dto.lorryInOutList = [];
      this.dto.shippingInOutList = [];
      this.dto.shippingList = [];
      this.dto.lorryList = [];
      this.dto.expressList = [];
      this.dto.airFreightsList = [];
      this.viewBtnFlag = "";
      this.visible = false;
    },
    //卡派入仓时间
    changeIntOutTime(date, dateString, record) {
      record.intOutTime = `${dateString} 23:59:59`;
    },
    //海运到仓时间
    changeShiEndTime(date, dateString, record) {
      record.shippingEndTime = `${dateString} 23:59:59`;
    },
    //开船时间
    changeShiStartTime(date, dateString, record) {
      record.shippingStartTime = `${dateString} 00:00:00`;
    },
    //改变航班时间
    changeFbaTime(date, dateString, record) {
      record.fbaStartTime = `${dateString} 00:00:00`;
    },
    //下载批量导入模板
    async upDowBtn() {
      let res = await upDow();
      const blob = new Blob([res], {
        type: "application/vnd.ms-excel",
      });
      const fileName = "入库申请批量导入模板.xlsx";
      const linkNode = document.createElement("a");
      linkNode.download = fileName; //a标签的download属性规定下载文件的名称
      linkNode.style.display = "none";
      linkNode.href = URL.createObjectURL(blob); //生成一个Blob URL
      document.body.appendChild(linkNode);
      linkNode.click(); //模拟在按钮上的一次鼠标单击
      URL.revokeObjectURL(linkNode.href); // 释放URL 对象
      document.body.removeChild(linkNode);
    },

    //头程改变快递方式
    changeexpressName(value, option, record) {
      record.expressId = value;
      record.expressName = option.data.attrs.name;
    },
    //尾程改变快递方式
    changeexpressNameWei(value, option, record) {
      record.expressId = value;
      record.expressName = option.data.attrs.name;
    },
    //改变卡派方式
    changeLorryChannelName(value, option, record) {
      record.lorryChannelId = value;
      record.lorryChannelName = option.data.attrs.name;
    },
    //改变车牌号
    changeLicensePlate(value, option, record) {
      record.licensePlate = option.data.attrs.name;
    },
    changeBusTypes(e) {
      if (e == "FBA转运") {
        this.dto.businessType = 0;
      } else if (e == "普通转运") {
        this.dto.businessType = 1;
      } else if (e == "其他仓库转运") {
        this.dto.businessType = 2;
      }
    },

    // 限制上传文件
    beforeUpload(file) {
      return new Promise((resolve, reject) => {
        this.files = file;
        const extension = file.name.split(".")[1] === "xls";
        const extension2 = file.name.split(".")[1] === "xlsx";
        if (!extension && !extension2) {
          this.$message.error("上传模板只能是 xls、xlsx格式!");
          return reject(false);
        }
        return resolve(true);
      });
    },
    // 限制上传文件
    beforeUploads(file) {
      return new Promise((resolve, reject) => {
        this.files = file;
        const isLt6M = file.size / 1024 / 1024 < 6;
        const pdf = file.type === "application/pdf";
        const img =
          file.type === "image/jpeg" ||
          file.type === "image/png" ||
          file.type === "image/jpg";
        if (!pdf && !img) {
          this.$message.error("上传文件只能是 png、jpeg、jpg、PDF!");
          return reject(false);
        }
        if (!isLt6M) {
          this.$message.error("文件大小限制小于6MB!");
          return reject(false);
        }
        return resolve(true);
      });
    },

    //导入文件
    importFile(info) {
      if (info.fileList && info.fileList.length >= 2) {
        this.fileList = info.fileList;
        info.fileList = info.fileList.splice(0, 1);
        this.$message.warning("只能上传一个文件！");
      }
      if (info.file.status === "done") {
        if (info.file.response.code === "200") {
          this.dataSource = info.file.response.responseBody.boxList;
          this.$message.success(`${info.file.name} 上传成功！`);
        } else if (info.file.response.code === "20024") {
          this.$message.error(info.file.response.message);
        } else if (info.file.response.code === "20026") {
          this.$message.error(info.file.response.message);
        }
      } else if (info.file.status === "error") {
        this.$message.error(`${info.file.name} 上传失败，请用上传模板上传哦.`);
      }
    },
    checkWarehouse(rule, value, callback) {
      if (!value) {
        callback(new Error("请选择入库仓库"));
        return false;
      } else {
        callback();
      }
    },
    //验证业务类型
    checkBusTypes(rule, value, callback) {
      if (!value) {
        callback(new Error("请选择业务类型"));
        return false;
      } else {
        callback();
      }
    },
    //验证发货物流名称
    checkFbaName(rule, value, callback) {
      if (this.dto.logisticsId === "201") {
        if (value === "") {
          callback(new Error("发货物流名称不能为空"));
        } else {
          callback();
        }
      } else if (this.dto.logisticsId === "202") {
        if (value === "") {
          callback(new Error("头程物流商不能为空"));
        } else {
          callback();
        }
      }
    },
    //验证发货物流名称
    checkFbaNumber(rule, value, callback) {
      if (this.dto.logisticsId === "201") {
        if (value === "") {
          callback(new Error("发货物流单号不能为空"));
        } else {
          callback();
        }
      }
      if (this.dto.logisticsId === "202") {
        if (value === "") {
          callback(new Error("头程物流号不能为空"));
        } else {
          callback();
        }
      }
    },
    //发货物流日期
    checkDeliveryTime(rule, value, callback) {
      if (this.dto.logisticsId === "201") {
        if (value === "" || value === null) {
          callback(new Error("发货物流日期不能为空"));
        } else {
          callback();
        }
      }
      if (this.dto.logisticsId === "202") {
        if (value === "" || value === null) {
          callback(new Error("航班日期不能为空"));
        } else {
          callback();
        }
      }
    },
    //货柜型号
    checkCargotankModel(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "" || value === undefined) {
          callback(new Error("货柜型号不能为空"));
        } else {
          callback();
        }
      }
    },
    //货柜船号
    checkHullNumber(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "" || value === null) {
          callback(new Error("货运船号不能为空"));
        } else {
          callback();
        }
      }
    },
    //货柜柜号
    checkCargotankNumber(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "") {
          callback(new Error("货运柜号不能为空"));
        } else {
          callback();
        }
      }
    },
    //HBL
    checkHbl(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "") {
          callback(new Error("HBL不能为空"));
        } else {
          callback();
        }
      }
    },
    //开船日期
    checkStartTime(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "" || value === null) {
          callback(new Error("开船日期不能为空"));
        } else {
          callback();
        }
      }
    },
    //到仓日期
    checkEndTime(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "" || value === null) {
          callback(new Error("到仓日期不能为空"));
        } else {
          callback();
        }
      }
    },
    //MBL
    checkMbl(rule, value, callback) {
      if (this.dto.logisticsId === "203") {
        if (value === "") {
          callback(new Error("MBL不能为空"));
        } else {
          callback();
        }
      }
    },
    //标签下载
    async tagDownload(data) {
      if (data.productTag === "") {
        this.$message.error("请选择SKU后进行下载操作！");
      } else {
        let res = await SKU_PDF6030(
          `top=${data.productTag}&&bottom=${data.sku}`
        );
        req.exportPDF("60*30mm", res);
      }
    },
    // 仓库改变
    changeWarehouse(value, option) {
      this.dto.warehousingId = value;
      this.dto.warehousingName = option.data.attrs.name;
      if (this.dto.warehousingName != "") {
        this.$refs.warehousing.$el.style.border = "none";
      }
    },
    // 尾程快递方式改
    changeLogisticsNameWei(value, option) {
      if (value == "201") {
        this.dto.logisticsTypeInOut = 0;
      } else if (value == "202") {
        this.dto.logisticsTypeInOut = 2;
      } else if (value == "203") {
        this.dto.logisticsTypeInOut = 1;
      } else if (value == "204") {
        this.dto.logisticsTypeInOut = 3;
      }
      this.dto.logisticsIdWei = value;
      this.dto.logisticsNameWei = option.data.attrs.name;
      if (this.dto.logisticsIdWei == "201") {
        this.expressListWei = [];
        this.dto.expressInOutList = [];
        this.dto.lorryInOutList = [];
        let expressListWei = {
          expressName: undefined,
          expressId: "",
          trackingNumber: "",
          goodsNo: "",
          uploadFile: {
            fileText: "",
            url: "",
          },
          uiIsDelete: null,
          inOutType: 1,

          key: this.expressListWei.length,
        };
        this.expressListWei.push(expressListWei);
      } else if (this.dto.logisticsIdWei == "204") {
        this.expressListWei = [];
        this.dto.expressInOutList = [];
        this.dto.lorryInOutList = [];
        //卡派
        let lorryList = {
          lorryChannelName: "", //卡派方式名称
          lorryChannelId: "", //卡派方式id
          licensePlate: "", //车牌号
          cargoNo: "", //货物编号
          intOutTime: "", //入仓时间
          uploadFile: {
            fileText: "",
            url: "",
          },
          inOutType: 1,
          uiIsDelete: null,
          key: this.expressListWei.length,
        };
        this.expressListWei.push(lorryList);
      } else {
        this.expressListWei = [];
      }
    },
    //尾程新增物流
    addLogiWei() {
      if (this.dto.logisticsIdWei == "201") {
        let expressListWei = {
          expressName: undefined,
          expressId: "",
          trackingNumber: "",
          goodsNo: "",
          uiIsDelete: null,
          inOutType: 1,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressList.length,
        };
        this.expressListWei.push(expressListWei);
      } else if (this.dto.logisticsIdWei == "204") {
        //卡派
        let lorryListWei = {
          lorryChannelName: "", //卡派方式名称
          lorryChannelId: "", //卡派方式id
          licensePlate: "", //车牌号
          cargoNo: "", //货物编号
          intOutTime: "", //入仓时间

          inOutType: 1,
          uiIsDelete: null,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressListWei.length,
        };
        this.expressListWei.push(lorryListWei);
      } else {
        this.$message.error("请先选择物流方式！");
      }
    },
    // 头程快递方式改
    changeLogisticsName(value, option) {
      if (value == "201") {
        this.dto.logisticsType = 0;
      } else if (value == "202") {
        this.dto.logisticsType = 2;
      } else if (value == "203") {
        this.dto.logisticsType = 1;
      } else if (value == "204") {
        this.dto.logisticsType = 3;
      }
      this.dto.logisticsId = value;
      this.dto.logisticsName = option.data.attrs.name;
      if (this.dto.logisticsId == "201") {
        this.dto.airFreightsList = [];
        this.dto.shippingList = [];
        this.dto.expressList = [];
        this.dto.lorryList = [];
        this.expressList = [];
        let expressList = {
          expressName: undefined,
          expressId: "",
          trackingNumber: "",
          goodsNo: "",
          inOutType: 0,
          uiIsDelete: null,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressList.length,
        };
        this.expressList.push(expressList);
      } else if (this.dto.logisticsId == "202") {
        this.expressList = [];
        this.dto.airFreightsList = [];
        this.dto.shippingList = [];
        this.dto.expressList = [];
        this.dto.lorryList = [];
        //空运
        let airFreightsList = {
          flightNo: "", //航班号
          fbaSeriveName: "", //头程物流商
          fbaLogisticsNo: "", //头程物流号
          fbaStartTime: "", //头程航班日期
          inOutType: 0,
          uiIsDelete: null,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressList.length,
        };
        this.expressList.push(airFreightsList);
      } else if (this.dto.logisticsId == "203") {
        this.expressList = [];
        this.dto.airFreightsList = [];
        this.dto.shippingList = [];
        this.dto.expressList = [];
        this.dto.lorryList = [];
        //海运
        let shippingList = {
          shippingNo: "", //头程货运船号
          shippingCabinetNo: "", //头程货运柜号
          shippingCabinetType: "", //头程货柜型号
          shippingHbl: "", //头程hbl
          shippingMbl: "", //头程货mbl
          shippingStartTime: "", //开船日期
          shippingEndTime: "", //到仓日期

          inOutType: 0,
          uploadFile: {
            fileText: "",
            url: "",
          },
          uiIsDelete: null,
          key: this.expressList.length,
        };
        this.expressList.push(shippingList);
      } else if (this.dto.logisticsId == "204") {
        this.expressList = [];
        this.dto.airFreightsList = [];
        this.dto.shippingList = [];
        this.dto.expressList = [];
        this.dto.lorryList = [];
        //卡派
        let lorryList = {
          lorryChannelName: "", //卡派方式名称
          lorryChannelId: "", //卡派方式id
          licensePlate: "", //车牌号
          cargoNo: "", //货物编号
          intOutTime: "", //入仓时间
          uploadFile: {
            fileText: "",
            url: "",
          },
          inOutType: 0,
          uiIsDelete: null,
          key: this.expressList.length,
        };
        this.expressList.push(lorryList);
      } else {
        this.expressList = [];
      }
    },
    //新增物流
    addLogi() {
      if (this.dto.logisticsId == "201") {
        let expressList = {
          expressName: undefined,
          expressId: "",
          trackingNumber: "",
          goodsNo: "",
          uiIsDelete: null,
          inOutType: 0,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressList.length,
        };
        this.expressList.push(expressList);
      } else if (this.dto.logisticsId == "202") {
        //空运
        let airFreightsList = {
          flightNo: "", //航班号
          fbaSeriveName: "", //头程物流商
          fbaLogisticsNo: "", //头程物流号
          fbaStartTime: "", //头程航班日期

          inOutType: 0,
          uploadFile: {
            fileText: "",
            url: "",
          },
          uiIsDelete: null,
          key: this.expressList.length,
        };
        this.expressList.push(airFreightsList);
      } else if (this.dto.logisticsId == "203") {
        //海运
        let shippingList = {
          shippingNo: "", //头程货运船号
          shippingCabinetNo: "", //头程货运柜号
          shippingCabinetType: "", //头程货柜型号
          shippingHbl: "", //头程hbl
          shippingMbl: "", //头程货mbl
          shippingStartTime: "", //开船日期
          shippingEndTime: "", //到仓日期
          inOutType: 0,
          uiIsDelete: null,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressList.length,
        };
        this.expressList.push(shippingList);
      } else if (this.dto.logisticsId == "204") {
        //卡派
        let lorryList = {
          lorryChannelName: "", //卡派方式名称
          lorryChannelId: "", //卡派方式id
          licensePlate: "", //车牌号
          cargoNo: "", //货物编号
          intOutTime: "", //入仓时间

          uiIsDelete: null,
          inOutType: 0,
          uploadFile: {
            fileText: "",
            url: "",
          },
          key: this.expressList.length,
        };
        this.expressList.push(lorryList);
      } else {
        this.$message.error("请先选择物流方式！");
      }
    },
    //SKU改变
    changeSku(option, item, record) {
      if (this.modalFlage == "add") {
        let flag = true;
        record.boxSkuList.forEach((v) => {
          if (option.data.attrs.sku === v.sku) {
            flag = false;
            item.sku = "";
            this.$message.error("同一箱子只能不能添加多个同名SKU！");
          }
        });
        if (flag) {
          item.chineseName = option.data.attrs.name;
          item.skuId = option.data.attrs.skuid;
          item.sku = option.data.attrs.sku;
          item.productTag = option.data.attrs.productTag;
        }
      } else if (this.modalFlage == "edit") {
        let flag = true;
        record.boxSkuList.forEach((v) => {
          if (option.data.attrs.sku === v.sku) {
            flag = false;
            item.sku = "";
            this.$message.error("同一箱子只能不能添加多个同名SKU！");
          }
        });
        if (flag) {
          item.chineseName = option.data.attrs.name;
          item.skuId = option.data.attrs.skuid;
          item.sku = option.data.attrs.sku;
          item.productTag = option.data.attrs.productTag;
          item.uiIsDelete = 2;
          // this.dto.boxList.forEach(val => {
          //   val.boxSkuList.forEach((key, j) => {
          //     if (
          //       key.byTransferWarehousingBoxSkuId ==
          //       item.byTransferWarehousingBoxSkuId
          //     ) {
          //       val.boxSkuList[j].uiIsDelete = 2;
          //       key.skuId = option.data.attrs.skuid;
          //       key.sku = option.data.attrs.sku;
          //       key.productTag = option.data.attrs.productTag;
          //     }
          //     if (!key.byTransferWarehousingBoxSkuId) {
          //       val.boxSkuList[j].uiIsDelete = null;
          //       key.skuId = option.data.attrs.skuid;
          //       key.sku = option.data.attrs.sku;
          //       key.productTag = option.data.attrs.productTag;
          //     }
          //   });
          // });
        }
      }
    },
    //新增每一行SKU
    addSku(record) {
      let rowDataPto = JSON.parse(JSON.stringify(record.boxSkuList));
      this.boxlistObj.key = Math.random();
      this.boxlistObj.skuId = "";
      this.boxlistObj.chineseName = "";
      this.boxlistObj.sku = "请选择SKU";
      this.boxlistObj.skuTotal = 1;
      this.boxlistObj.uiIsDelete = null;
      rowDataPto.push(Object.assign({}, this.boxlistObj));
      if (this.modalFlage == "add") {
        this.dataSource.forEach((item, index) => {
          item.uiIsDelete = null;
          if (record.key === item.key) {
            this.dataSource[index].boxSkuList = rowDataPto;
          }
        });
      } else if (this.modalFlage == "edit") {
        //点击新增的时候标识修改过该数据
        this.dataSource.forEach((item, index) => {
          if (record.key === item.key) {
            this.dataSource[index].boxSkuList = rowDataPto;
            // this.dto.boxList[index].boxSkuList = rowDataPto;
          }
        });
      }
    },
    //删除每一行SKU
    delSku(record, item) {
      if (record.boxSkuList.length == 1) {
        this.$message.error("每个箱子最少存放一个SKU！");
        return false;
      }
      if (this.modalFlage == "add") {
        record.boxSkuList.forEach((v, i) => {
          if (v.sku === item.sku) {
            record.boxSkuList.splice(i, 1);
          }
        });
      } else if (this.modalFlage == "edit") {
        record.boxSkuList.forEach((v, i) => {
          if (v.sku === item.sku) {
            record.boxSkuList.splice(i, 1);
          }
        });
      }
    },
    //接受明细按钮
    acceptDetail() {
      setTimeout(() => {
        this.$bus.$emit("acceptTheDetail2", this.dto);
      }, 10);
    },
    //箱子接收情况
    async sreachBoxInfo(applyId) {
      let { responseBody } = await warehousingBoxInfo(applyId);
      this.boxAcceptedTotal = responseBody.boxAcceptedTotal;
      this.boxTotal = responseBody.boxTotal;
    },
    //接受箱子
    async receive(record) {
      let { code, responseBody } = await searchBoxInfo(
        this.dto.transferWarehousingApplyId,
        record.transferWarehousingBoxId,
        { current: 1, size: 10000 }
      );
      if (code == "200") {
        let arr = [];
        record.boxSkuList.forEach((item) => {
          arr.push(item.sku);
        });
        let skus = arr.join(",");
        let data = {
          batchNo: this.dto.transferNo,
          boxAcceptedTotal: responseBody.boxAcceptedTotal,
          boxTotal: responseBody.boxTotal,
          boxWaitTotal: responseBody.boxWaitTotal,
          cargoCard: null,
          customBoxNo: responseBody.customBoxNo,
          goodsBoxNo: responseBody.goodsBoxNo,
          skus: skus,
          revision: responseBody.revision,
          warehouseId: this.dto.warehousingId,
          warehousingId: null,
          warehousingName: null,
          transferWarehousingApplyId: this.dto.transferWarehousingApplyId,
          transferWarehousingBoxId: responseBody.transferWarehousingBoxId,
        };
        setTimeout(() => {
          this.$bus.$emit("acceptTheDetail", data);
        }, 10);
      }
    },
    //新增箱子
    async addBox() {
      let { code, responseBody } = await box_no();
      if (code === "200") {
        let boxList = {
          boxSkuList: [],
          goodsBoxNo: "",
          customBoxNo: "",
          height: "",
          boxTotal: "",
          long: "",
          weight: "",
          width: "",
          uiIsDelete: null,
          isCheck: "",
          Counting: false,
        };
        boxList.goodsBoxNo = responseBody;
        boxList.key = responseBody;
        let obj = Object.assign({}, this.boxlistObj);
        obj.sku = "请选择SKU";
        obj.key = this.dataSource.length;
        let arr = JSON.parse(JSON.stringify(boxList.boxSkuList));
        arr.push(obj);
        boxList.boxSkuList = arr;
        this.dataSource.push(boxList);
      }
    },
    //新建入库确认
    handleOk() {
      if (this.modalFlage == "info") {
        this.visible = false;
        this.loading = false;
        return;
      }
      this.loading = true;
      this.dataSource.forEach((item) => {
        if (item.Counting == false) {
          item.isCheck = "0";
        } else {
          item.isCheck = "1";
        }
        if (
          item.height != "" &&
          item.long != "" &&
          item.width != "" &&
          item.weight != ""
        ) {
          this.passFlag = true;
        } else {
          this.passFlag = false;
          this.loading = false;
          return false;
        }
        if (item.boxTotal >= 1 && item.boxTotal != undefined) {
          this.passFlag = true;
        } else {
          this.passFlag = false;
          this.loading = false;
          return false;
        }
        item.boxSkuList.forEach((v) => {
          if (v.chineseName != "") {
            this.passFlag = true;
          } else {
            this.passFlag = false;
            return false;
          }
        });
        // if(this.dto.logisticsType==''){
        //   this.$message.error('请先选择物流方式！')
        //   return false
        // }
      });
      //快进快出转换
      if (this.isFast == true) {
        this.dto.fastInOut = 1;
      } else {
        this.dto.fastInOut = 0;
      }
      //根据选择不同的物流类型来添加不同的提交数据
      if (this.modalFlage == "add") {
        this.expressList.forEach((item) => {
          item.uploadFile = JSON.stringify(item.uploadFile);
        });
        this.expressListWei.forEach((item) => {
          item.uploadFile = JSON.stringify(item.uploadFile);
        });
        //头程
        if (this.dto.logisticsId == "201") {
          this.dto.expressList = this.expressList;
        } else if (this.dto.logisticsId == "202") {
          this.dto.airFreightsList = this.expressList;
        } else if (this.dto.logisticsId == "203") {
          this.dto.shippingList = this.expressList;
        } else if (this.dto.logisticsId == "204") {
          this.dto.lorryList = this.expressList;
        }
        //尾程
        if (this.dto.logisticsIdWei == "201") {
          this.dto.expressInOutList = this.expressListWei;
        } else if (this.dto.logisticsIdWei == "204") {
          this.dto.lorryInOutList = this.expressListWei;
        }
      } else if (this.modalFlage == "edit") {
        if (this.expressList.length > 0) {
          this.expressList.forEach((item) => {
            if (typeof item.uploadFile === "object") {
              item.uploadFile = JSON.stringify(item.uploadFile);
            }
          });
        }
        if (this.expressListWei.length > 0) {
          this.expressListWei.forEach((item) => {
            if (typeof item.uploadFile === "object") {
              item.uploadFile = JSON.stringify(item.uploadFile);
            }
          });
        }
        //头程
        if (this.dto.logisticsId == "201") {
          let newArr = this.expressList.filter((item) => {
            return !item.byLogisticsExpressId;
          });
          let newArr2 = this.expressList.filter((item) => {
            return item.byLogisticsExpressId;
          });
          this.dto.expressList = newArr2;
          if (newArr.length > 0) {
            this.dto.expressList = this.dto.expressList.concat(newArr);
          }
          this.dto.expressList.forEach((item) => {
            item.uploadFile = JSON.stringify(item.uploadFile);
          });
        } else if (this.dto.logisticsId == "202") {
          let newArr = this.expressList.filter((item) => {
            return !item.byLogisticsAirFreightId;
          });
          let newArr2 = this.expressList.filter((item) => {
            return item.byLogisticsAirFreightId;
          });
          this.dto.airFreightsList = newArr2;
          if (newArr.length > 0) {
            this.dto.airFreightsList = this.dto.airFreightsList.concat(newArr);
          }
          this.dto.airFreightsList.forEach((item) => {
            item.uploadFile = JSON.stringify(item.uploadFile);
          });
        } else if (this.dto.logisticsId == "203") {
          let newArr = this.expressList.filter((item) => {
            return !item.byLogisticsShippingId;
          });
          let newArr2 = this.expressList.filter((item) => {
            return item.byLogisticsAirFreightId;
          });
          this.dto.shippingList = newArr2;
          if (newArr.length > 0) {
            this.dto.shippingList = this.dto.shippingList.concat(newArr);
          }
          this.dto.shippingList.forEach((item) => {
            item.uploadFile = JSON.stringify(item.uploadFile);
          });
        } else if (this.dto.logisticsId == "204") {
          let newArr = this.expressList.filter((item) => {
            return !item.byLogisticsLorryId;
          });
          let newArr2 = this.expressList.filter((item) => {
            return item.byLogisticsAirFreightId;
          });
          this.dto.lorryList = newArr2;
          if (newArr.length > 0) {
            this.dto.lorryList = this.dto.lorryList.concat(newArr);
          }
          this.dto.lorryList.forEach((item) => {
            item.uploadFile = JSON.stringify(item.uploadFile);
          });
        }
        //尾程
        if (this.dto.logisticsIdWei == "201") {
          let newArr = this.expressListWei.filter((item) => {
            return !item.byLogisticsAirFreightId;
          });
          let newArr2 = this.expressListWei.filter((item) => {
            return item.byLogisticsAirFreightId;
          });
          this.dto.expressInOutList = newArr2;
          if (newArr.length > 0)
            this.dto.expressInOutList =
              this.dto.expressInOutList.concat(newArr);
          this.dto.expressInOutList.forEach((item) => {
            item.uploadFile = JSON.stringify(item.uploadFile);
          });
        } else if (this.dto.logisticsIdWei == "204") {
          let newArr = this.expressListWei.filter((item) => {
            return !item.byLogisticsLorryId;
          });
          let newArr2 = this.expressListWei.filter((item) => {
            return item.byLogisticsLorryId;
          });
          this.dto.lorryInOutList = newArr2;
          if (newArr.length > 0) {
            this.dto.lorryInOutList = this.dto.lorryInOutList.concat(newArr);
          }
          this.dto.lorryInOutList.forEach((item) => {
            item.uploadFile = JSON.stringify(item.uploadFile);
          });
        }
      }
      if (this.passFlag) {
        if (this.dto.logisticsId === "未选择") {
          this.dto.logisticsId = "";
        }
        if (this.dto.logisticsIdWei === "未选择") {
          this.dto.logisticsIdWei = "";
        }

        //如果没选快进快出的话只用验证上面的表单

        if (!this.isFast) {
          this.submitFun();
        } else {
          this.$refs.addForm.validate((valid) => {
            this.$refs.inOutForm.validate((valid1) => {
              if (valid && valid1) {
                if (this.modalFlage === "add") {
                  setTimeout(async () => {
                    this.dto.boxList = this.dataSource;
                    let { code } = await transferIn_save(this.dto);
                    if (code === "10000") {
                      this.getTransferInTableList();
                      this.getStateCount(0);
                      this.getStateCount(1);
                      this.getStateCount(2);
                      this.getStateCount(3);
                      this.getStateCount(4);
                      this.getStateCount(5);
                      this.loading = false;
                      this.visible = false;
                      this.reload();
                    } else {
                      //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                      if (this.expressList.length > 0) {
                        this.expressList.forEach((item) => {
                          if (typeof item.uploadFile === "string") {
                            item.uploadFile = JSON.parse(item.uploadFile);
                          }
                        });
                      }
                      if (this.expressListWei.length > 0) {
                        this.expressListWei.forEach((item) => {
                          if (typeof item.uploadFile === "string") {
                            item.uploadFile = JSON.parse(item.uploadFile);
                          }
                        });
                      }
                      this.loading = false;
                    }
                  }, 1000);
                } else if (this.modalFlage === "edit") {
                  if (this.tabKeys === "30") {
                    if (this.dto.logisticsId === "") {
                      this.$message.error("请完善头程信息！");
                      this.loading = false;
                      return false;
                    } else if (this.dto.logisticsId != "") {
                      setTimeout(async () => {
                        let { code } = await update_ascertained(
                          this.dto.transferWarehousingApplyId,
                          this.dto
                        );
                        if (code === "10000") {
                          this.getTransferInTableList();
                          this.getStateCount(0);
                          this.getStateCount(1);
                          this.getStateCount(2);
                          this.getStateCount(3);
                          this.getStateCount(4);
                          this.getStateCount(5);
                          this.loading = false;
                          this.visible = false;
                          this.reload();
                        } else {
                          //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                          if (this.expressList.length > 0) {
                            this.expressList.forEach((item) => {
                              if (typeof item.uploadFile === "string") {
                                item.uploadFile = JSON.parse(item.uploadFile);
                              }
                            });
                          }
                          if (this.expressListWei.length > 0) {
                            this.expressListWei.forEach((item) => {
                              if (typeof item.uploadFile === "string") {
                                item.uploadFile = JSON.parse(item.uploadFile);
                              }
                            });
                          }
                          this.loading = false;
                        }
                      }, 1000);
                    }
                  } else {
                    setTimeout(async () => {
                      this.dto.boxList = this.dataSource;
                      let { code } = await updateApplyInfo(
                        this.dto.transferWarehousingApplyId,
                        this.dto
                      );
                      if (code === "10000") {
                        this.getTransferInTableList();
                        this.getStateCount(0);
                        this.getStateCount(1);
                        this.getStateCount(2);
                        this.getStateCount(3);
                        this.getStateCount(4);
                        this.getStateCount(5);
                        this.loading = false;
                        this.visible = false;
                        this.reload();
                      } else {
                        //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                        if (this.expressList.length > 0) {
                          this.expressList.forEach((item) => {
                            if (typeof item.uploadFile === "string") {
                              item.uploadFile = JSON.parse(item.uploadFile);
                            }
                          });
                        }
                        if (this.expressListWei.length > 0) {
                          this.expressListWei.forEach((item) => {
                            if (typeof item.uploadFile === "string") {
                              item.uploadFile = JSON.parse(item.uploadFile);
                            }
                          });
                        }
                        this.loading = false;
                      }
                    }, 1000);
                  }
                }
              } else {
                //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                if (this.expressList.length > 0) {
                  this.expressList.forEach((item) => {
                    if (typeof item.uploadFile === "string") {
                      item.uploadFile = JSON.parse(item.uploadFile);
                    }
                  });
                }
                if (this.expressListWei.length > 0) {
                  this.expressListWei.forEach((item) => {
                    if (typeof item.uploadFile === "string") {
                      item.uploadFile = JSON.parse(item.uploadFile);
                    }
                  });
                }
                this.loading = false;
              }
            });
          });
        }
      } else {
        //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
        if (this.expressList.length > 0) {
          this.expressList.forEach((item) => {
            if (typeof item.uploadFile === "string") {
              item.uploadFile = JSON.parse(item.uploadFile);
            }
          });
        }
        if (this.expressListWei.length > 0) {
          this.expressListWei.forEach((item) => {
            if (typeof item.uploadFile === "string") {
              item.uploadFile = JSON.parse(item.uploadFile);
            }
          });
        }
        this.$message.error("必填项缺失！请检测必填项是否完整！");
        this.loading = false;
      }
    },
    submitFun() {
      this.$refs.addForm.validate((valid) => {
        if (valid) {
          if (this.modalFlage === "add") {
            setTimeout(async () => {
              this.dto.boxList = this.dataSource;
              let { code } = await transferIn_save(this.dto);
              if (code === "10000") {
                this.getTransferInTableList();
                this.getStateCount(0);
                this.getStateCount(1);
                this.getStateCount(2);
                this.getStateCount(3);
                this.getStateCount(4);
                this.getStateCount(5);
                this.loading = false;
                this.visible = false;
                this.reload();
              } else {
                //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                if (this.expressList.length > 0) {
                  this.expressList.forEach((item) => {
                    if (typeof item.uploadFile === "string") {
                      item.uploadFile = JSON.parse(item.uploadFile);
                    }
                  });
                }
                if (this.expressListWei.length > 0) {
                  this.expressListWei.forEach((item) => {
                    if (typeof item.uploadFile === "string") {
                      item.uploadFile = JSON.parse(item.uploadFile);
                    }
                  });
                }
                this.loading = false;
              }
            }, 1000);
          } else if (this.modalFlage === "edit") {
            if (this.tabKeys === "30") {
              if (this.dto.logisticsId === "") {
                this.$message.error("请完善头程信息！");
                this.loading = false;
                return false;
              } else if (this.dto.logisticsId != "") {
                setTimeout(async () => {
                  let { code } = await update_ascertained(this.dto.id);
                  if (code === "10000") {
                    this.getTransferInTableList();
                    this.getStateCount(0);
                    this.getStateCount(1);
                    this.getStateCount(2);
                    this.getStateCount(3);
                    this.getStateCount(4);
                    this.getStateCount(5);
                    this.loading = false;
                    this.visible = false;
                  } else {
                    //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                    if (this.expressList.length > 0) {
                      this.expressList.forEach((item) => {
                        if (typeof item.uploadFile === "string") {
                          item.uploadFile = JSON.parse(item.uploadFile);
                        }
                      });
                    }
                    if (this.expressListWei.length > 0) {
                      this.expressListWei.forEach((item) => {
                        if (typeof item.uploadFile === "string") {
                          item.uploadFile = JSON.parse(item.uploadFile);
                        }
                      });
                    }

                    this.loading = false;
                  }
                }, 1000);
              }
            } else {
              setTimeout(async () => {
                this.dto.boxList = this.dataSource;
                let { code } = await updateApplyInfo(
                  this.dto.transferWarehousingApplyId,
                  this.dto
                );
                if (code === "10000") {
                  this.getTransferInTableList();
                  this.getStateCount(0);
                  this.getStateCount(1);
                  this.getStateCount(2);
                  this.getStateCount(3);
                  this.getStateCount(4);
                  this.getStateCount(5);
                  this.loading = false;
                  this.visible = false;
                } else {
                  //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
                  if (this.expressList.length > 0) {
                    this.expressList.forEach((item) => {
                      if (typeof item.uploadFile === "string") {
                        item.uploadFile = JSON.parse(item.uploadFile);
                      }
                    });
                  }
                  if (this.expressListWei.length > 0) {
                    this.expressListWei.forEach((item) => {
                      if (typeof item.uploadFile === "string") {
                        item.uploadFile = JSON.parse(item.uploadFile);
                      }
                    });
                  }
                  this.loading = false;
                }
              }, 1000);
            }
          }
        } else {
          //如果失败的话再把它转回对象，上面点击提交的时候会转回字符串
          if (this.expressList.length > 0) {
            this.expressList.forEach((item) => {
              if (typeof item.uploadFile === "string") {
                item.uploadFile = JSON.parse(item.uploadFile);
              }
            });
          }
          if (this.expressListWei.length > 0) {
            this.expressListWei.forEach((item) => {
              if (typeof item.uploadFile === "string") {
                item.uploadFile = JSON.parse(item.uploadFile);
              }
            });
          }
          this.loading = false;
          return false;
        }
      });
    },
    // 审核页面确认
    chcekBtn(flag) {
      if (flag === "recei") {
        this.loading = true;
        setTimeout(async () => {
          let { code } = await updateWaitSendFba(
            this.dto.transferWarehousingApplyId,
            "1",
            this.dto.revision
          );
          if (code === "10000") {
            this.getTransferInTableList();
            this.getStateCount(0);
            this.getStateCount(1);
            this.getStateCount(2);
            this.getStateCount(3);
            this.getStateCount(4);
            this.getStateCount(5);
            this.getStateCount(6);
            this.loading = false;
            this.visible = false;
          }
        }, 1000);
      } else if (flag === "back") {
        this.loading = true;
        setTimeout(async () => {
          let { code } = await backautit4(
            this.dto.transferWarehousingApplyId,
            "1",
            this.dto.revision
          );
          if (code === "10000") {
            this.getTransferInTableList();
            this.getStateCount(0);
            this.getStateCount(1);
            this.getStateCount(2);
            this.getStateCount(3);
            this.getStateCount(4);
            this.getStateCount(5);
            this.getStateCount(6);
            this.loading = false;
            this.visible = false;
          }
        }, 1000);
      }
    },
    // 下拉框过滤
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text
          .toLowerCase()
          .indexOf(input.toLowerCase()) >= 0
      );
    },
    // //费用信息
    // changeCost(checkedValues) {
    //   this.costValue = checkedValues;
    //   this.dto.feeType = checkedValues.join(",");
    // },
    //删除头程当前行物流方式
    DeleteLogi(row, key) {
      if (this.modalFlage == "add") {
        this.expressList.forEach((item, index) => {
          if (item.key == key) {
            this.expressList.splice(index, 1);
          }
        });
      } else if (this.modalFlage == "edit") {
        this.expressList.forEach((item, index) => {
          if (item.byLogisticsLorryId) {
            if (item.byLogisticsLorryId == row.byLogisticsLorryId) {
              this.dto.lorryList[index].uiIsDelete = 1;
              this.expressList.splice(index, 1);
            }
          } else if (item.byLogisticsAirFreightId) {
            if (item.byLogisticsAirFreightId == row.byLogisticsAirFreightId) {
              this.dto.airFreightsList[index].uiIsDelete = 1;
              this.expressList.splice(index, 1);
            }
          } else if (item.byLogisticsExpressId) {
            if (item.byLogisticsExpressId == row.byLogisticsExpressId) {
              this.dto.expressList[index].uiIsDelete = 1;
              this.expressList.splice(index, 1);
            }
          } else if (item.byLogisticsShippingId) {
            if (item.byLogisticsShippingId == row.byLogisticsShippingId) {
              this.dto.shippingList[index].uiIsDelete = 1;
              this.expressList.splice(index, 1);
            }
          } else {
            if (item.key == key) {
              this.expressList.splice(index, 1);
            }
          }
        });
      }
    },
    //删除尾程行物流方式
    DeleteLogiWei(row, key) {
      if (this.modalFlage == "add") {
        this.expressListWei.forEach((item, index) => {
          if (item.key == key) {
            this.expressListWei.splice(index, 1);
          }
        });
      } else if (this.modalFlage == "edit") {
        this.expressListWei.forEach((item, index) => {
          if (item.byLogisticsLorryId) {
            if (item.byLogisticsLorryId == row.byLogisticsLorryId) {
              this.dto.lorryInOutList[index].uiIsDelete = 1;
              this.expressListWei.splice(index, 1);
            }
          } else if (item.byLogisticsAirFreightId) {
            if (item.byLogisticsAirFreightId == row.byLogisticsAirFreightId) {
              this.dto.airFreightsInOutList[index].uiIsDelete = 1;
              this.expressListWei.splice(index, 1);
            }
          } else if (item.byLogisticsExpressId) {
            if (item.byLogisticsExpressId == row.byLogisticsExpressId) {
              this.dto.expressInOutList[index].uiIsDelete = 1;
              this.expressListWei.splice(index, 1);
            }
          } else if (item.byLogisticsShippingId) {
            if (item.byLogisticsShippingId == row.byLogisticsShippingId) {
              this.dto.shippingInOutList[index].uiIsDelete = 1;
              this.expressListWei.splice(index, 1);
            }
          } else {
            if (item.key == key) {
              this.expressListWei.splice(index, 1);
            }
          }
        });
      }
    },
    //文件上传
    async handle(info, record) {
      if (info.file.status !== "uploading") {
        if (info.fileList.length >= 2) {
          this.fileList = info.fileList.concat();
          info.fileList = info.fileList.splice(0, 1);
          this.$message.warning("只能上传一个文件！");
        }
      }
      if (info.file.status === "done") {
        if (info.file.response.code === "200") {
          record.uploadFile.url = info.file.response.responseBody[0];
          record.uploadFile.fileText = info.file.name;
        }
        this.$message.success(`${info.file.name} 上传成功！`);
      } else if (info.file.status === "error") {
        this.$message.error(`${info.file.name} 上传失败！请重新试试！`);
      }

      if (info.file.status === "removed") {
        let { code } = await removefile(info.file.response.responseBody);
        if (code === "10000") {
          record.uploadFile.url = "";
          record.uploadFile.fileText = "";
        }
      }
    },
    //获取下拉框选择值
    async getSelection() {
      //调仓库
      let { code, responseBody } = await warehouse_select({
        warehousePid: 0,
      });
      if (code === "200") {
        this.warehouse = responseBody;
      }
      //调快递方式
      let res = await treeTagDictionary({
        tagType: 4,
      });
      if (res.code === "200") {
        //自己加个卡派进去

        res.responseBody.push({ key: "204", title: "卡派方式" });
        this.express = res.responseBody;
      }
      let value = await sku_select();
      if (value.code === "200") {
        this.skuList = value.responseBody;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.ant-form-inline .ant-form-item-with-help {
  margin: 0;
}
.zxmx {
  display: flex;
  margin-bottom: 15px;
  align-content: center;
  flex-wrap: wrap;
  /deep/.ant-form-item:first-child {
    .ant-form-item-control-wrapper {
      width: 100%;
    }
  }
  > div {
    display: flex;
    margin-right: 15px;
  }
  /deep/.fast {
    .ant-form-item-children {
      display: flex;
      align-items: center;
      .ant-checkbox-wrapper {
        width: 120px;
      }
      .ant-input {
        width: 80%;
      }
    }
  }
}

/deep/.columns-tab {
  width: 10% !important;
  .ant-table-header-column {
    width: 100%;
    .columns {
      display: flex;

      div {
        flex: 1;
        text-align: center;
        border: 1px solid #ccc;
      }
    }
  }
}
.row-btn {
  font-size: 18px;
  i {
    margin: 0 5px;
    cursor: pointer;
  }
}
/deep/.box-sizes {
  width: 22px;
  display: flex;
  input {
    width: 50px;
    flex: 1;
  }
}
.boxSkuList-list {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  li {
    flex: 1;
    border: 1px solid #ccc;
    padding: 3px 0;

    // line-height: 2rem;
  }
}
/deep/.ant-modal-footer {
  text-align: center !important;
  button {
    margin: 0 50px;
  }
}
.box-handle {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e8e8e8;
  border-bottom: 0;
  padding: 5px 10px;
  .handle-right {
    padding-left: 10px;
    border-left: 1px solid #e8e8e8;
    width: 70%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
.wei-logi {
  width: 100%;
  display: flex;
  justify-content: space-between;
  .ant-form-item {
    display: flex;
    margin-right: 20px;
    flex: 1;
  }
  /deep/.fastaddr {
    flex: 1;
    .ant-form-item-control-wrapper {
      width: 100%;
    }
    .ant-form-item-label {
      padding-right: 20px !important;
    }
    input {
      width: 80%;
    }
  }
}
</style>
